{include file="public_head"}
{include file="public_menu"}
    <div class="content_main" style="min-height: 1000px;">
        <!--领券中心广告-->
        <!--<div class="main_pic" style="height:350px;background: url('__STATIC__/img/pic37.png') no-repeat center;">-->
            <!--<a href="#"></a>-->
        <!--</div>-->
        <!--领券中心广告-->

        <!--优惠券列表-->
        <ul class="list_coupon">
            {volist name="data" id="vo"}
                {empty name="vo.member_coupon"}
            <li style="background: url('__STATIC__/img/bg11.png') no-repeat 100% 100%;">
                {else/}
            <li style="background: url('__STATIC__/img/yilingqu.png') no-repeat 100% 100%;">
                {/empty}
                <div class="media">
                    <div class="media-left media-middle">

                        <img class="media-object" src="/{$vo.GoodsType.picUrl}" onerror="this.src='__STATIC__/img/pic38.png'">

                    </div>
                    <div class="media-body media-middle">
                        <div class="price">￥<span>{$vo.actual_price}</span></div>
                        <div class="tips">满{$vo.virtual_price}元减{$vo.actual_price}元<br>{$vo.title}<br>{:date('Y-m-d',$vo.start_time)}至{:date('Y-m-d',$vo.end_time)}<br>限{$vo.GoodsType.title}分类商品使用</div>
                    </div>
                </div>
                {empty name="vo.member_coupon"}
                <div class="get_coupon" style="cursor:pointer" onclick="receive_coupons({$vo.id})"><a href="#">立<br>即<br>领<br>取</a></div>
                {else/}
                <div class="get_coupon"><a>已<br>经<br>领<br>取</a></div>
                {/empty}
            </li>
           {/volist}
        </ul>
        <!--优惠券列表-->

    </div>
<div class="pages">{$data->render();}</div>
<script>
    // 领取优惠券
    function receive_coupons(cid) {
        $.ajax({
            url:"{:url('Coupon/receive_coupons')}",
            dataType:'json',
            type:'post',
            data:{'coupon_id':cid},
            success:function (t) {
                if (t.code == 200){
                    layer.msg('恭喜你领取成功！');
                    setTimeout(function () {
                        location.reload();
                    }, 2000);

                }else if (t.code == 401){
                    layer.msg(t.message);
                }else{
                    layer.msg(t.message);
                    setTimeout(function () {
                        window.location="{:url('shop/login/index')}";
                    }, 3000);

                }
            }
        })
    }
</script>
{include file="public_foot"}